<?php
  INCLUDE "F_CONX.php";
  $V_REPORTE  =  $HTTP_POST_VARS["V_REPORTE2"];
  $V_ANIO     =  $HTTP_POST_VARS["V_ANIO2"];
  $V_MES      =  $HTTP_POST_VARS["V_MES2"];
  $V_EDOZONA  =  $HTTP_POST_VARS["V_EDOZONA2"];
  ECHO $V_ANIO."<BR>";
  SWITCH ($V_REPORTE)
  {     CASE "CAVEN"  :	$V_CAMPO = "USU"; BREAK;
     CASE "CEDOVE" :	$V_CAMPO = "VTA"; BREAK;
     CASE "CAVEZO" :	$V_CAMPO = "PRO"; BREAK;  }

  $V_OUT="";
  $V_OUT.="<HTML>";
  $V_OUT.="<HEAD>";
  $V_OUT.="<TITLE></TITLE>";
  $V_OUT.="</HEAD>";
  $V_OUT.="<FORM NAME='FORMCAP' METHOD='POST' ACTION='R_XLS.php'>
           <TABLE WIDTH='800'>
           <TR><TD COLSPAN='13'>$V_REPORTE</TD></TR>
           <TR><TD>TARIFA</TD>";
  FOREACH($A_DMESES AS $V_DMES)
  {
    $V_OUT.="<TD>$V_DMES</TD>";
  }
  $V_OUT.="</TR>";

  $MS_SQL    = "SELECT * FROM TFAS";
  $MS_RESULT = MYSQL_QUERY($MS_SQL);
  WHILE($A_TFAS = MYSQL_FETCH_ARRAY($MS_RESULT))
  {
    $V_OUT.="<TR><TD>$A_TFAS[0]</TD>";
    $MS_SQL="SELECT $V_CAMPO FROM datos WHERE TAR = '$A_TFAS[0]' AND ZONA = '$V_EDOZONA' AND MES = '$V_MES' AND ANIO = '$V_ANIO'";
    ECHO $MS_SQL."<BR>";
    $MS_RESULT1=MYSQL_QUERY($MS_SQL);
    WHILE ($A_DATOS = MYSQL_FETCH_ARRAY($MS_RESULT1))
    {
      $V_OUT.="<TD>$A_DATOS[0]</TD>";
    }
    $V_OUT.="</TR>";
  }
  $V_OUT.="<TR><TD COLSPAN='4'><INPUT TYPE='SUBMIT' NAME='BTN_ENVIO' VALUE='GENERAR ARCHIVO...'></TD></TR>";
  $V_OUT.="</TABLE></FORM>";
  $V_OUT.="</BODY>";
  $V_OUT.="</HTML>";
  ECHO $V_OUT;
?>
